package cn.groupmarket.domain.activity.service.discount.impl;

import cn.groupmarket.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import cn.groupmarket.domain.activity.service.discount.AbstractDiscountCalculateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Slf4j
@Service("ZJ")
public class ZJCalculateService extends AbstractDiscountCalculateService {
    @Override
    protected BigDecimal doCalculate(BigDecimal originalPrice, GroupBuyActivityDiscountVO.GroupBuyDiscount discount) {
        String marketExpr = discount.getMarketExpr();
        BigDecimal subtract = originalPrice.subtract(new BigDecimal(marketExpr));
        if(subtract.compareTo(BigDecimal.ZERO) <= 0){
            return new BigDecimal("0.01");
        }
        return subtract;
    }
}
